 package srdb.migration.dbhandler.enterprisedb;
 
 
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.sql.SQLException;
 import java.util.ArrayList;
import java.util.List;

import srdb.migration.common.MTKData;
import srdb.migration.common.MTKMetaData;
 
 public class OfflineData extends MTKData
 {
   private List fileList = new ArrayList();
 
   public void setTableData(String tableName, InputStream pis, char copyDelimiter) throws Exception
   {
     OutputStream os = null;
     Exception ex = null;
     try {
       os = openStream(tableName);
       byte[] buffer = new byte[512];
       int size = 0;
       while ((size = pis.read(buffer)) > 0)
         os.write(buffer, 0, size);
     }
     catch (Exception exp) {
       ex = exp; } finally {
       try {
         os.close(); } catch (Exception e) {
       }
     }
     if (ex != null)
       throw ex;
   }
 
   public int setTableDataViaDBLinkOra(String tableName, String targetSchema, String targetTable, boolean truncate)
     throws SQLException
   {
     throw new UnsupportedOperationException("OfflineData => setTableDataViaDBLinkOra -> Not supported yet.");
   }
 
   public OutputStream openStream(String tableName) throws FileNotFoundException {
     boolean append = this.fileList.contains(tableName);
     FileOutputStream fos = new FileOutputStream(MTKMetaData.offlineMigrationSchemaDDLFilePath + File.separator + "mtk_" + tableName.replace(".", "_").toLowerCase() + "_data.cpy", append);
     if (!append) {
       this.fileList.add(tableName);
     }
     return fos;
   }
 }

/* 

 * 
 */